package com.water.service.staticservice;

import com.water.service.IService;
import com.water.service.TeamService;

/**
 * @author wsj
 * @version 1.0
 * @description: TODO
 * @date 2022/1/9 12:59
 */
//这是二级代理-事务
public class ProxyTranService implements IService {
    private IService teamService;

    public ProxyTranService(IService teamService) {
        this.teamService = teamService;
    }

    @Override
    public void add() {
        try{
            System.out.println("===开始事务======");
            teamService.add();//被代理对象执行核心业务
            System.out.println("=====提交事务=====");
        }catch (Exception e){
            System.out.println("======回滚事务====");
        }
    }
}
